package org.dzl.springboot001.controller;

import org.dzl.springboot001.service.RedisService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 光的代言人
 */
@RestController
@RequestMapping("redis")
public class RedisController {
    private final RedisService redisService;

    public RedisController(RedisService redisService) {
        this.redisService = redisService;
    }

    @GetMapping("add")
    public String add(String key, String value){
        redisService.setString(key,value);
        return "redis test";
    }

    @GetMapping("get")
    public String get(String key){
        return "redis:"+redisService.getString(key);
    }
}
